﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RandomGeneratorForm
{
    public partial class RandomGeneratorHTMLcontrols : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblResult.InnerText = "loaded";
        }

        protected void GenerateNumber(object sender, EventArgs e)
        {
            Random generator = new Random();
            try
            {
                int from = int.Parse(txtFrom.Value);
                int to = int.Parse(txtTo.Value);
                this.lblResult.InnerText = generator.Next(from, to).ToString();
            }
            catch (Exception)
            {
                this.lblResult.InnerText = "Error occured!";
            }
            
        }
    }
}